﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommandLine;
using CommandLine.Text;
using System.IO;
using System.Runtime.Serialization;


namespace FileListBuilder
{
    class XMLWriter : IWriter
    {
        public void Write(Options options,List<Document> lstDocuments )
        {
            string sCompleteFileName = options.StartDirectory + "\\" + options.OutputFilename + "." + options.OutputFileFormat;
            Program.Log(0, "Start writing result file in " + sCompleteFileName, options);
            FileStream writer = new FileStream(sCompleteFileName, FileMode.Create);
            DataContractSerializer ser = new DataContractSerializer(typeof(List<Document>));
            ser.WriteObject(writer, lstDocuments);
            writer.Close();
            Program.Log(0, "End writing result file", options);
        }
    }
}
